import api from './index'
import request from "../utils/request";

//admin
//登录
export function loginByPwdAdmin(uname,pass){
  const data = {
    username:uname,
    password:pass
  }
  return request(
    {
      url:api.loginByPwdAdmin,
      method:'post',
      data
    },
  )
}
export function loginBySmsAdmin(phone,code){
  const data = {
    phone:phone,
    str:code
  }
  return request(
    {
      url:api.loginBySmsAdmin,
      method:'post',
      data
    },
  )
}
export function loginSmsAdmin(phone){
  const data = {
    phone:phone
  }
  return request(
    {
      url:api.loginSmsAdmin,
      method:'post',
      data
    },
  )
}

//用户
export function loginByPwdUser(uname,pass){
  const data = {
    username:uname,
    password:pass
  }
  return request(
    {
      url:api.loginByPwdUser,
      method:'post',
      data
    },
  )
}
//用户登录时发送短信
export function loginSmsUser(phone){
  const data = {
    phone:phone
  }
  return request(
    {
      url:api.loginSmsUser,
      method:'post',
      data
    },
  )
}
//短信登录
export function loginBySmsUser(telnumber,verifiCode){
  const data={
    phone:telnumber,
    str:verifiCode
  }
  return request({
    url:api.loginBySmsUser,
    method:'post',
    data
  })
}
//注册用户
export function registeUser(username,tel,str,pass,sequ,context,TenementName){
  const data = {
    username: username,
    password: pass,
    telnumber: tel,
    str: str,
    securityQuestionAnswer: sequ,
    securityQuestionContext: context,
    TenementName:TenementName
  }

  return request({
    url:api.registerUser,
    method:'post',
    data
  })
}
//注册用户时发送短信
export function registersmsUser(phone){
  const data = {
    phone:phone
  }
  return request({
    url:api.registersmsUser,
    method:'post',
    data
  })
}




//答者
//密码登录
export function loginByPwdAnswerer(uname,pass){
  const data = {
    username:uname,
    password:pass
  }
  return request({
    url:api.loginByPwdAnswerer,
    method:'post',
    data
  })
}
//短信登录
export function loginBySmsAnswerer(phone,code){
  const data = {
    phone:phone,
    str:code

  }
  return request({
    url:api.loginBySmsAnswerer,
    method:'post',
    data
  })
}
//答者登录时发送短信
export function loginSmsAnswerer(phone){
  const data = {
    phone:phone
  }
  return request({
    url:api.loginSmsAnswerer,
    method:'post',
    data
  })
}
//注册
//注册答者时发送短信
export function registersmsAnswerer(phone){
  const data = {
    phone:phone
  }
  return request({
    url:api.registersmsAnswerer,
    method:'post',
    data
  })
}
//发送短信后注册
export function registerAnswerer(name,tel,str,pass,se,cont){
  const data = {
    username: name,
    password: pass,
    telnumber: tel,
    str: str,
    securityQuestionAnswer: se,
    securityQuestionContext: cont
  }
  console.log("答者注册的信息")
  console.log(data)
  return request({
    url:api.registerAnswerer,
    method:'post',
    data
  })
}


//租户
//登录
export function loginSmsTenement(phone){
  const data = {
    phone:phone
  }
  return request({
    url:api.loginSmsTenement,
    method:'post',
    data
  })
}
export function loginByPwdTenement(uname,pass){
  const data = {
    username:uname,
    password:pass
  }
  return request({
    url:api.loginByPwdTenement,
    method:'post',
    data
  })
}
export function loginBySmsTenement(phone,code){
  const data = {
    phone:phone,
    str:code
  }
  return request({
    url:api.loginBySmsTenement,
    method:'post',
    data
  })
}
//注册
export function registersmsTenement(phone){
  const data = {
    phone:phone
  }
  return request({
    url:api.registersmsTenement,
    method:'post',
    data
  })
}
export function registerTenement(uname,phone,code,pass
,answer,question){
  const data = {
    username:uname,
    password:pass,
    telnumber:phone,
    str:code,
    securityQuestionAnswer:answer,
    securityQuestionContext:question
  }
  return request({
    url:api.registerTenement,
    method:'post',
    data
  })
}






